package huawei.exam4;

import java.util.*;

/**
 * @author : Rookie
 * @description :
 * @date : 2023/5/31
 */
public class HJ86 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        String binaryString = Integer.toBinaryString(num);
        System.out.println(countContinuousOne(binaryString));
    }

    private static int countContinuousOne(String bs) {
        // 二进制数只有一位，直接返回
        if (bs.length() == 1) {
            return Integer.parseInt(bs);
        }
        // 记录连续的1的个数
        int count = 0;
        List<Integer> numList = new ArrayList<>();
        for (int i = 0; i < bs.length(); i++) {
            char c = bs.charAt(i);
            int num = Integer.parseInt(String.valueOf(c));
            if (num == 1) {
                count ++;
            } else {
                numList.add(count);
                count = 0;
            }
        }
        numList.add(count);
        return numList.stream().max(Integer::compareTo).get();
    }
}
